/*
 * @Description:
 * @Author: 稽辉
 * @Date: 2025-02-05 09:42:19
 * @LastEditTime: 2025-03-17 15:40:42
 * @LastEditors: 稽辉
 */
import type { CartItem } from '@/types/cart'
import { http } from '@/utils/http'

//购物车添加API
export const postMemberCartAPI = (data: { goodId: string; count: number; userId: number }) => {
  return http({
    method: 'POST',
    url: '/cart/add-good-to-cart',
    data,
  })
}

//购物车获取API
export const getMemberCartAPI = (userId: number) => {
  return http<CartItem[]>({
    method: 'GET',
    url: `/cart/get-cart-goods/${userId}`,
  })
}
//购物车删除API
export const deleteMemberCartAPI = (data: string[], userId: number) => {
  return http<number>({
    method: 'DELETE',
    url: `/cart/delete-cart-goods/${userId}`,
    data,
  })
}
//更新对应购物车单品API
export const putMemberCartBySkuIdAPI = (data: {
  selected?: boolean
  count?: number
  goodId: string
  userId: number
}) => {
  return http({
    method: 'PUT',
    url: `/cart/update-cart-good`,
    data,
  })
}
//购物车全选接口
export const putMemberCartSelectedAPI = (selected: boolean, userId: number) => {
  return http({
    method: 'PUT',
    url: `/cart/cart-select-all/${selected}/${userId}`,
  })
}
